<template>
	<view class="content">
		<view class="login">
			<view class="login-top">欢迎</view>
			<view class="logobox">
				<img src="@/static/logo2.png" alt="" class="logo" />
				捌加壹采购
			</view>
			<view class="login-center clearfix" style="margin-bottom: 20rpx;">
				<up-input prefixIcon="account" v-model="username" fontSize="32rpx" placeholder="账号" border="bottom"
					prefixIconStyle="font-size:40rpx;color:#0B9EE2" clearable></up-input>
				<view style="height: 20rpx;">

				</view>
				<up-input prefixIcon="lock" v-model="password" fontSize="32rpx" placeholder="密码" border="bottom" type="password"
					prefixIconStyle="font-size:40rpx;color:#0B9EE2" clearable></up-input>
			</view>
			<view class="login-center clearfix">
				<navigator style="float:right;color: #AAACB2;font-size: 28rpx;" url="/pages/forgetPwd/forgetPwd1">
					忘记密码?
				</navigator>
			</view>
			<view class="login-button" @click="submit">登陆</view>
		</view>
	</view>
</template>

<script>
	import { http } from 'uview-plus'
	export default {
		data() {
			return {
				username: '',
				password: '',
			};
		},
		onLoad() {},
		methods: {
			async submit() {
				var that =this
				if (that.username == '') {
					uni.showToast({
						title: "请输入账号",
						icon: 'none'
					})
					return
				}
				if (that.password == '') {
					uni.showToast({
						title: "请输入密码",
						icon: 'none'
					})
					return
				}
				await http.post('/shop/user/login',{username:that.username,password:that.password}).then(res => {
						console.log(res)
						uni.setStorage({
						    key: 'token',
						    data: res.token,
						    success: function () {
								uni.showToast({
									title:'登陆成功',
									icon:'success'
								})
								getApp().get_shopping_List()
								uni.navigateBack({
									delta:2
								})
						    }
						});
				});
			},
		}
	};
</script>

<style>
	.clearfix:after {
		visibility: hidden;
		display: block;
		font-size: 0;
		content: ' ';
		clear: both;
		height: 0;
	}

	.cli {
		clear: both;
		font-size: 0;
		height: 0;
		overflow: hidden;
		display: block;
	}

	.lclear {
		clear: left;
		font-size: 0;
		height: 0;
		overflow: hidden;
	}

	.fl {
		float: left;
	}

	.fr {
		float: right;
	}

	.content {}

	.login {
		width: 350px;
		border-radius: 5px;
		height: 500px;
		background: white;
		margin: auto;
	}

	.login-top {
		font-size: 64rpx;
		margin-top: 201rpx;
		padding-left: 40px;
		box-sizing: border-box;
		color: #333333;
		margin-bottom: 50px;
	}

	.logobox {
		display: flex;
		flex-direction: column;
		align-items: center;
		font-size: 48rpx;
		color: #1B1B1B;
		margin-bottom: 100rpx;
	}

	.logo {
		width: 114rpx;
		height: 106rpx;
		margin-bottom: 20rpx;
	}

	.login-center {
		width: 600rpx;
		margin: auto;
		box-sizing: border-box;
		margin-bottom: 30px
	}

	.login-button {
		cursor: pointer;
		width: 654rpx;
		height: 90rpx;
		line-height: 90rpx;
		border-radius: 16px;
		opacity: 1;
		text-align: center;
		background: #08AFFE;
		margin: 0 auto;
		margin-top: 50px;
		font-size: 36rpx;
		font-weight: normal;
		color: #FFFFFF;
	}
</style>